<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
</head>
<body class="gray-bg">
	<div class="container creditbody">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷后业务>资料归档登记</span>
		</div>
		<div class="buttonfixed">
			<button type="button" class="btn dpbtn_blue btnaplly"
				onclick="save();">保存提交</button>
		</div>
		<div class="ibox-content ibox-con">
			<form class="form-horizontal" id="commentForm">
				<%@include file="/jsp/comm_yw_info_include.jsp"%>
				<div class="business-manwife">归档信息</div>
				<div class="business-padding">
					<table cellpadding="0" cellspacing="0" border="0"
						class="buyinfor-table">
						<tr>
							<td align="right"><label class="control-label np">档案编号：</label>
							</td>
							<td><input id="noRecord" name="" onblur="checkDataByNo();"
								class="form-control" type="text" required="required"
								placeholder="档案编号(必填)" /></td>
							<td align="right"><label class="control-label np">归档日期：</label>
							</td>
							<td><input id="dateArchive" name="dateArchive"
								placeholder="请输入时间(必填)" required="required"
								class="laydate-icon form-control" onclick="laydate()" 
								placeholder="归档日期(必填)" /></td>
						</tr>
						<tr>
							<td align="right"><label class="control-label np">存放位置：</label>
							</td>
							<td colspan="3"><input id="locationStore" name=""
								class="form-control" type="text"  placeholder="存放位置" /></td>
						</tr>
						<tr>
							<td align="right" valign="top"><label
								class="control-label np">信息备注：</label></td>
							<td colspan="3"><textarea id="remarks" name="remarks"
									class="form-control" type="text" placeholder="信息备注"></textarea>
							</td>
						</tr>
					</table>
				</div>
				<div class="business-manwife">经办信息</div>
				<div class="padding-nono">
					<table cellpadding="0" cellspacing="0" border="0"
						class="buyinfor-table">
						<tr>
							<td align="right"><label class="control-label np">经办人：</label>
							</td>
							<td><input class="form-control" type="text" id="operate"
								name="" readonly="readonly" value="${current_user_key.uname}" />
							</td>
							<td align="right"><label class="control-label np">经办时间：</label>
							</td>
							<td><input id="operateTime" name="operateTime"
								class="form-control" onclick="laydate()"
								placeholder="经办时间" readonly="readonly"/></td>
						</tr>
					</table>

				</div>
			</form>
		</div>
	</div>
	</div>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>
	<!-- summernote -->
	<%@include
		file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>

	<!-- layerDate plugin javascript -->
	<script type="text/javascript"
		src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    jQuery(function($) { 
	    	getDataByBusiId();
	    	$("#dateArchive").val(laydate.now());
	    	$("#operateTime").val(laydate.now())
	    });
	    
	    $(function(){ 
	         $("#commentForm").validate({
	             //重写showErrors
	             showErrors: function (errorMap, errorList) {
	                 
	                 $.each(errorList, function (i, v) {
	                     layer.tips(v.message, v.element, { time: 1500 });
	                     return false;
	                 });  
	             },
	             /* 失去焦点时验证 */
	             onfocusout: function(element) { $(element).valid(); },
	             /*  键盘抬起不验证 */
	             onkeyup:false,
	         });
	  	});
	    var flag=true;
	    var checkDataByNo=function(){
	    	var data={};
	    	noRecord=$("#noRecord").val();
	    	if(noRecord && noRecord !=""){
		    	data.noRecord=$("#noRecord").val();
		    	$.dpAjax({
		    		url:'${basePath}/DhArchiveController/list',
		    		data:data,
	    			success: function(datas){
		    			  if(datas.flag == "100100")
						  {
		    				  if(datas.result.rows.length>0){
			    				  flag=false;
								  layer.tips('档案编号已经存在！', '#noRecord');
		    				  }else{
		    					  flag=true; 
		    				  }
							  return;
						  }
						  if(datas.flag == "100200")
		                  {
							  $.fn.showDatas({"datas":datas});
		                	  return;
		                  }
	                 }
		    	});
	    	}
	    }
	    var getDataByBusiId=function(){
	    	var data={};
	    	data.busiId=$.getUrlData("busiId");
	    	$.dpAjax({
	    		show:false,
	    		url:'${basePath}/DhArchiveController/list',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				var data=datas.result.rows;
	    				if(data.length>0){
	    					$("#noRecord").val(data[0].noRecord);
		    			    $("#locationStore").val(data[0].locationStore);
		    			    $("#dateArchive").val(data[0].dateArchive);
		    			    $("#remarks").val(data[0].remarks);
		    			    $("#dateArchive").val(data[0].dateArchive);
	    				}
	    				
						  layer.msg('执行成功！', {icon: 6});
						  
						  return;
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    var save=function(){
	    	if(flag==false){
	    		layer.tips('档案编号已经存在！', '#noRecord');
	    		return;
	    	}
	    	var validstatus = $("#commentForm").valid();
   	    	if(validstatus)
   	    	{
		    	var data={};
		    	data.noRecord=$("#noRecord").val();
		    	data.locationStore=$("#locationStore").val();
		    	data.dateArchive=$("#dateArchive").val();
		    	data.remarks=$("#remarks").val();
		    	data.dateArchive=$("#dateArchive").val();
		    	data.creatorName=$("#operate").val();
		    	data.creator="${current_user_key.id}";
		    	data.jbDate=$("#operateTime").val();
		    	data.busiId=$.getUrlData("busiId");
		    	data.cusId=$.getUrlData("cusId");
		    	layer.confirm('您确认要提交吗？', {
		  			  btn: ['确定','取消'] //按钮
					},function(){
					layer.closeAll();
			    	$.dpAjax({
			    		url:'${basePath}/DhArchiveController/save',
			    		data:data,
		    			success: function(datas){
			    			  if(datas.flag == "100100")
							  {
			    				  window.location.href="dataArchiving.jsp";
								  layer.msg('执行成功！', {icon: 6});
								  
								  return;
							  }
							  if(datas.flag == "100200")
			                  {
								  $.fn.showDatas({"datas":datas});
			                	  return;
			                  }
		                 }
			    	});
				});	
   	    	}	
	    }
		
    </script>
</body>
</html>
